package com.songlanyun.modules.distributionconfig.controller.admin;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.songlanyun.common.annotation.SysLog;
import com.songlanyun.modules.distributionconfig.model.DistributionShopConfigDTO;
import com.songlanyun.modules.user.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.songlanyun.modules.distributionconfig.entity.DistributionShopConfig;
import com.songlanyun.modules.distributionconfig.service.DistributionShopConfigService;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;



/**
 * 商家分销设置，用来管控店铺分销的开启与关闭，分销佣金算法和算法数据
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2020-12-22 11:43:24
 */
@RestController
@RequestMapping("admin/distributionshopconfig")
public class DistributionShopConfigAdminController extends AbstractController {
    @Autowired
    private DistributionShopConfigService distributionShopConfigService;


    /**
     * 查看商家自营商品统一分销设置
     */
    @RequestMapping("/info")
    //@RequiresPermissions("distributionconfig:distributionshopconfig:info")
    public R info(){
		DistributionShopConfig distributionShopConfig = distributionShopConfigService.getByShop(getShopId(true));
        return R.ok().put("data", distributionShopConfig);
    }

    /**
     * 保存商家自营商品统一分销设置
     * @param dto
     * @return
     */
    @SysLog("保存商家自营商品统一分销设置")
    @RequestMapping("/set")
    //@RequiresPermissions("distributionconfig:distributionshopconfig:save")
    public R set(@RequestBody DistributionShopConfigDTO dto){
        DistributionShopConfig distributionShopConfig =distributionShopConfigService.set(getShopId(true),dto);
        return R.ok().put("data", distributionShopConfig);
    }

}
